﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once
#include "GbmpCommon.h"
#include "GcmpFoundation.h"

#include <cstdint>


namespace gcmp
{
    /// \brief 用来表示软件运行期的唯一标识
    /// 
    /// \see Element
    class GCMP_FOUNDATION_EXPORT RuntimeId
    {
    public:
        DEFINE_VISUAL_TYPE_INT64(gcmp::IntBaseType::Dec)

    public:
        /// \brief 构造函数
        /// 
        /// 默认id为Invalid(-1) 
        FORCE_INLINE explicit RuntimeId(Int32 id = -1) : m_id(id) {}

        /// \brief 判断当前RuntimeId是否有效
        /// \return bool true-有效的  false-无效的
        FORCE_INLINE bool IsValid() const { return m_id >= 0; }

        /// \brief 获取当前RuntimeId 的数值表达
        /// \return int32 RuntimeId的数值表达
        FORCE_INLINE Int32 AsInt32() const { return m_id; }
        
        /// \brief 重载==操作符
        /// \param 需要对比的目标Id
        /// \return bool true-相同， false-不相同
        FORCE_INLINE bool operator == (const RuntimeId& another) const { return m_id == another.m_id; }

        /// \brief 重载!=操作符
        /// \param 需要对比的目标Id
        /// \return bool true-不相同， false-相同
        FORCE_INLINE bool operator != (const RuntimeId& another) const { return m_id != another.m_id; }

        /// \brief 重载<操作符
        /// \param 需要对比的目标Id
        /// \return bool true-当前Id小于目标Id
        FORCE_INLINE bool operator < (const RuntimeId& another) const { return m_id < another.m_id; }

        /// \brief 重载>操作符
        /// \param 需要对比的目标Id
        /// \return bool true-当前Id大于目标Id
        FORCE_INLINE bool operator > (const RuntimeId& another) const { return m_id > another.m_id; }

        /// \brief 重载++运算符，Prefix ++
        FORCE_INLINE RuntimeId& operator ++ () { ++m_id; return *this; }

        /// \brief 重载++运算符，Postfix ++
        FORCE_INLINE RuntimeId operator ++ (int) { RuntimeId old(*this); m_id++; return old; }

    public:
        /// \brief 获取当前RuntimeId的数值表示
        /// \return int id数值
        int GetId()const {return int(m_id);}

        

    public:
        static const RuntimeId InvalidID;
        /// \brief 设置当前RuntimeId
        /// \param  id 需要设置的id值
        void SetId(Int32 id ) {m_id = id;}

    private:
        Int32 m_id;
    };
}



